
// {
// let a = 123
// let aaa = {}
// const obj = 48651
// Object.assign(aaa, obj)
// console.log(aaa)
// }.
{
    const obj = { name: `zhangsan`, age: 19 }
    let newObj = { ...obj, age: 20 }
    console.log(newObj)
}

{
    const a = { name: `zhangsan`, age: 19 }
    const b = { a: 2, v: 3 }
    let x = { ...a, ...b }
    console.log(x)

}

{
    let a = `zhanhsan`;
    let b = `52`;
    let c = {
        a,
        b,
        d() {
            console.log(`this is dog`)
        }
    }
    console.log(c)
    c.d()
}

{
    let set = new Set();
    set.add(1);
    console.log(set)
    let newSet = new Set([1, 1, 2, 2, 3, 3, 4, 4, 5]);
    console.log(newSet)
    console.log(newSet.has(5))
}

{
    let set = new Set([1, 2, 3, 4, 5]);
    for (let s of set.keys()) {
        console.log(s)
    }
}

{
    const arr = [1, 2, 3, 1, 2, 3, 4, 1, 3, 4, 33]
    let newarr = new Set(arr);
    console.log(newarr);
    let otherdata = Array.from(newarr);
    console.log(otherdata)
}

{
    let obj = { name: `zhangsan` };
    let weakSet = new WeakSet()
    weakSet.add(obj)
    console.log(weakSet)
}

{
    let obj = {
        name: "zs",
        hohhy: "eating"
    }
    console.log(Object.entries(obj));
    let map = new Map(Object.entries(obj));
    console.log(map)
}

{
    let obj = {
        name: "zs",
        hohhy: "eating"
    }
    console.log(Object.entries(obj));
    let map = new Map(Object.entries(obj));
    console.log(map)
    let obj2 = Object.fromEntries(map);
    console.log(obj2)
}

{
    //Proxy代理
    let account = {
        name: `admin`,
        phone: `1234567890`,
        creat_time: `2021`
    }
    let accountProxy = new Proxy(account, {
        get(target, key) {
            switch (key) {
                case `phone`:
                    return target[key].substring(0, 3) + `****` + target[key].substring(7)
                case "creat_time":
                    return target[key].replace(`2021`, `2020`)
            }
        }
    })
    console.log(accountProxy.phone)
    console.log(accountProxy.creat_time)
}

{
    const obj = { name: `zhangsan`, age: 15, info:{ height: 162 }};
    let personOther = {}
    Object.assign(personOther,obj);
    obj.info.height = 150;
    console.log(personOther)


}

{
    let json = {name:`zhangsan`,age:`20`,size:`30`,weight:`3`};
    let obj = {};
    for (let s of Object.keys(json)){
        obj[s] = json[s]
    }
    console.log(obj)
}

{
    let json = {name:`zhangsan`,age:`20`,size:`30`,weight:`3`};
    let obj = {};
    for (let s of Object.values(json)){
        obj[s] = json[s]
    }
    console.log(obj)
}

{
    let json = {name:`zhangsan`,age:`20`,size:`30`,weight:`3`};
    let obj = {};
    for (let s of Object.entries(json)){
        obj[s] = json[s]
    }
    console.log(obj)
}



